"""
容易收敛到局部最优解(解决方法: 多次聚类)
"""
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score

# 应用场景: 没有目标值
# 1.降维
# 2.预估器
data_new = [[1,1],[1,2],[2,3],[4,5],[1,4]]
estimator = KMeans(n_clusters=3)
estimator.fit(data_new)
y_predict = estimator.predict(data_new)
# 3.模型评估 轮廓系数(-1, 1),越大越好
score = silhouette_score(data_new, y_predict)
print(score)
